<?php

namespace App\Services\Draw;

use App\Exceptions\BasicException;
use App\Services\Draw\DrawObject\Draw;

/**
 * 优惠券类
 * @author
 */
class DrawManager
{
    private $drawObject;

    public function __construct($drawType)
    {
        $this->drawObject = (new DrawFactory())->make($drawType);
    }

    public function checkIsOpen()
    {
        $isOpen = $this->drawObject->checkIsOpen();
        if (!$isOpen) {
            throw new BasicException(600000, '游戏正在抢修中~');
        }
    }

    public function getNotifyGiftList($count)
    {
        return $this->drawObject->getNotifyGiftList($count);
    }

    public function getCriticalGiftList()
    {
        return $this->drawObject->getCriticalGiftList();
    }

    public function getLevelList()
    {
        return $this->drawObject->getLevelList();
    }

    public function getPoolConfig()
    {
        return $this->drawObject->getPoolConfig();
    }


    public function getUserDrawInfo($userId)
    {
        return $this->drawObject->getUserDrawInfo($userId);
    }

    public function getRankList($userId, $type, $limit)
    {
        return $this->drawObject->getRankList($userId, $type, $limit);
    }

    public function getAllPrizeList()
    {
        return $this->drawObject->getAllPrizeList();

    }

    public function getAllPlutocratList()
    {
        return $this->drawObject->getAllPlutocratList();

    }

    public function getFragmentGroupList()
    {
        return $this->drawObject->getFragmentGroupList();
    }

    public function swapBalance(int $userId, int $drawCount)
    {
        return $this->drawObject->swapBalance($userId, $drawCount);
        //获取用户抽奖的池子
    }

    public function draw(int $userId, int $drawCount, $balanceId = 0)
    {
        return $this->drawObject->draw($userId, $drawCount, $balanceId);
        //获取用户抽奖的池子
    }

    public function setAuto(int $userId, int $is_auto)
    {
        return $this->drawObject->setAuto($userId, $is_auto);
    }

    public function prizeListByValue(int $perPage, int $page)
    {
        return $this->drawObject->prizeListByValue($perPage, $page);
    }

    public function getFragmentUserRecordList(int $prePage, int $page, int $userId, int $type)
    {
        return $this->drawObject->getFragmentUserRecordList($prePage, $page, $userId, $type);
    }

    public function drawRecord(int $perPage, int $page, int $userId)
    {
        return $this->drawObject->drawRecord($perPage, $page, $userId);
    }
}
